export const tableChangeMixin = {
  data() {
    return {
      /* 分页参数 */
      ipagination: {
        // index: 1,
        // pageSize: 10,
        // pageSizeOptions: ['10', '20', '30', '100'],


        total: 0,
        pageSizeOptions: [5, 10, 15, 20],
        index: 1,
        pageSize: 10,
      }
    }
  },
  methods: {
    updateIpagination(res) {
      this.ipagination.total = +res.data.total || (res.data.total == 0 ? 0 : this.ipagination.total);
      this.ipagination.index = +res.data.current || this.ipagination.index;
      this.ipagination.pageSize = +res.data.size || this.ipagination.pageSize;
    },
    /**
     * 分页组件：每页显示条数变化时触发
     * val:页面中选择的新页面条数
     */
    handleSizeChange(pageSize) {
		console.log(pageSize)
    this.ipagination.pageSize = pageSize
      // 由于修改了每页显示的条数，应当将页数还原为默认值 1
      this.ipagination.index == 1 &&  this.loadResources({
        index: 1,
        pageSize
      });
    },
    /**
     * 分页组件：页号改变触发
     * val:页面选择的当前页数
     */
    handleCurrentChange(index) {
      this.loadResources({
        index
      });
    },
  }
}
